<!--<!DOCTYPE html>-->
<!--&lt;!&ndash;<html lang="en">&ndash;&gt;-->
<!--&lt;!&ndash;<head>&ndash;&gt;-->
<!--&lt;!&ndash;    <meta charset="UTF-8">&ndash;&gt;-->
<!--&lt;!&ndash;    <title>登录</title>&ndash;&gt;-->
<!--&lt;!&ndash;</head>&ndash;&gt;-->
<!--&lt;!&ndash;<body>&ndash;&gt;-->
<!--&lt;!&ndash;<form action="/login" method="post">&ndash;&gt;-->
<!--&lt;!&ndash;    <label for="username">用户名：</label>&ndash;&gt;-->
<!--&lt;!&ndash;    <input type="text" id="username" name="username" required><br>&ndash;&gt;-->
<!--&lt;!&ndash;    <label for="password">密码：</label>&ndash;&gt;-->
<!--&lt;!&ndash;    <input type="password" id="password" name="password" required><br>&ndash;&gt;-->
<!--&lt;!&ndash;    <input type="submit" value="登录">&ndash;&gt;-->
<!--&lt;!&ndash;</form>&ndash;&gt;-->
<!--&lt;!&ndash;</body>&ndash;&gt;-->
<!--&lt;!&ndash;</html>&ndash;&gt;-->
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>用户登录</title>
    <!-- 引入基础样式 -->
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
        }

        body {
            background-color: #f5f7fa;
            min-height: 100vh;
            display: flex;
            justify-content: center;
            align-items: center;
            padding: 20px;
        }

        .login-container {
            width: 100%;
            max-width: 400px;
            background: white;
            padding: 30px;
            border-radius: 10px;
            box-shadow: 0 2px 15px rgba(0, 0, 0, 0.05);
        }

        .login-title {
            text-align: center;
            margin-bottom: 25px;
            color: #333;
            font-size: 24px;
            font-weight: 600;
        }

        .form-group {
            margin-bottom: 20px;
        }

        label {
            display: block;
            margin-bottom: 8px;
            color: #555;
            font-size: 14px;
            font-weight: 500;
        }

        .input-wrapper {
            position: relative;
        }

        input[type="text"],
        input[type="password"] {
            width: 100%;
            padding: 12px 15px 12px 40px;
            border: 1px solid #ddd;
            border-radius: 6px;
            font-size: 16px;
            transition: all 0.3s ease;
        }

        input:focus {
            outline: none;
            border-color: #4285f4;
            box-shadow: 0 0 0 3px rgba(66, 133, 244, 0.1);
        }

        .input-icon {
            position: absolute;
            left: 12px;
            top: 50%;
            transform: translateY(-50%);
            color: #999;
            font-size: 18px;
        }

        .password-toggle {
            position: absolute;
            right: 12px;
            top: 50%;
            transform: translateY(-50%);
            color: #999;
            cursor: pointer;
            font-size: 18px;
            background: none;
            border: none;
            padding: 2px;
        }

        .password-toggle:hover {
            color: #333;
        }

        .remember-me {
            display: flex;
            align-items: center;
            margin: 15px 0 25px;
        }

        .remember-me input {
            margin-right: 8px;
            width: 16px;
            height: 16px;
        }

        .remember-me label {
            margin: 0;
            color: #666;
            font-size: 14px;
            cursor: pointer;
        }

        button[type="submit"] {
            width: 100%;
            padding: 13px;
            background-color: #4285f4;
            color: white;
            border: none;
            border-radius: 6px;
            font-size: 16px;
            font-weight: 500;
            cursor: pointer;
            transition: background-color 0.3s ease;
        }

        button[type="submit"]:hover {
            background-color: #3367d6;
        }

        .error-message {
            background-color: #ffebee;
            color: #d32f2f;
            padding: 12px;
            border-radius: 6px;
            margin-bottom: 20px;
            font-size: 14px;
            display: none;
        }

        .error-message.show {
            display: block;
        }

        .footer-links {
            text-align: center;
            margin-top: 20px;
        }

        .footer-links a {
            color: #4285f4;
            text-decoration: none;
            font-size: 14px;
            margin: 0 5px;
        }

        .footer-links a:hover {
            text-decoration: underline;
        }

        .separator {
            color: #ccc;
        }
    </style>
    <!-- 引入图标 -->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
</head>
<body>
<div class="login-container">
    <h1 class="login-title">账户登录</h1>

    <!-- 错误提示 -->
    <div class="error-message" id="errorMsg">
        <i class="fas fa-exclamation-circle"></i>
        <span>用户名或密码错误，请重试</span>
    </div>

    <!-- 登录表单 -->
    <form method="post" action="/login">
        <!-- CSRF令牌（与Spring Security配合必需） -->
        <input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}">

        <!-- 用户名输入 -->
        <div class="form-group">
            <label for="username">用户名</label>
            <div class="input-wrapper">
                <i class="fas fa-user input-icon"></i>
                <input type="text" id="username" name="username"
                       placeholder="请输入用户名" required>
            </div>
        </div>

        <!-- 密码输入 -->
        <div class="form-group">
            <label for="password">密码</label>
            <div class="input-wrapper">
                <i class="fas fa-lock input-icon"></i>
                <input type="password" id="password" name="password"
                       placeholder="请输入密码" required>
                <button type="button" class="password-toggle" id="togglePwd">
                    <i class="fas fa-eye-slash"></i>
                </button>
            </div>
        </div>

        <!-- 记住我选项 -->
        <div class="remember-me">
            <input type="checkbox" id="remember-me" name="remember-me">
            <label for="remember-me">记住登录状态</label>
        </div>

        <!-- 登录按钮 -->
        <button type="submit">登录</button>

        <!-- 辅助链接 -->
        <div class="footer-links">
            <a href="/forgot-password">忘记密码?</a>
            <span class="separator">|</span>
            <a href="/register">注册账户</a>
        </div>
    </form>
</div>

<script>
    // 密码显示/隐藏切换
    const toggleBtn = document.getElementById('togglePwd');
    const passwordInput = document.getElementById('password');

    toggleBtn.addEventListener('click', () => {
        const type = passwordInput.getAttribute('type') === 'password' ? 'text' : 'password';
        passwordInput.setAttribute('type', type);

        // 切换图标
        const icon = toggleBtn.querySelector('i');
        icon.classList.toggle('fa-eye');
        icon.classList.toggle('fa-eye-slash');
    });

    // 处理URL中的错误参数（如登录失败后跳转）
    document.addEventListener('DOMContentLoaded', () => {
        const urlParams = new URLSearchParams(window.location.search);
        if (urlParams.has('error')) {
            document.getElementById('errorMsg').classList.add('show');
        }
    });
</script>
</body>
</html>
